﻿namespace CodeContrib.Web.Mvc.Html
{
	//public static class LabelExtensions
	//{
	//	public static MvcHtmlString Label(this HtmlHelper htmlHelper, string expression, string labelText)
	//	{
	//		return LabelHelper(htmlHelper, ModelMetadata.FromStringExpression(expression, htmlHelper.ViewData), expression, labelText, null);
	//	}

	//	public static MvcHtmlString Label(this HtmlHelper htmlHelper, string expression, string labelText, object htmlAttributes)
	//	{
	//		return LabelHelper(htmlHelper, ModelMetadata.FromStringExpression(expression, htmlHelper.ViewData), expression, labelText, htmlAttributes);
	//	}

	//	public static MvcHtmlString LabelFor<TModel, TValue>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TValue>> expression, object htmlAttributes)
	//	{
	//		return LabelHelper(htmlHelper, ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData), ExpressionHelper.GetExpressionText(expression), null, htmlAttributes);
	//	}

	//	public static MvcHtmlString LabelFor<TModel, TValue>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TValue>> expression, string labelText, object htmlAttributes)
	//	{
	//		return LabelHelper(htmlHelper, ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData), ExpressionHelper.GetExpressionText(expression), labelText, htmlAttributes);
	//	}

	//	internal static MvcHtmlString LabelHelper(HtmlHelper htmlHelper, ModelMetadata metadata, string htmlFieldName, string labelText, object htmlAttributes)
	//	{
	//		string resolvedLabelText = labelText ?? metadata.DisplayName ?? metadata.PropertyName ?? htmlFieldName.Split('.').Last();

	//		if (string.IsNullOrEmpty(resolvedLabelText))
	//		{
	//			return MvcHtmlString.Empty;
	//		}

	//		TagBuilder label = new TagBuilder("label");
	//		label.MergeAttributes(htmlAttributes.ToHtmlAttributes());
	//		label.Attributes["for"] = TagBuilder.CreateSanitizedId(htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(htmlFieldName));
	//		label.SetInnerText(resolvedLabelText);

	//		return MvcHtmlString.Create(label.ToString());
	//	}
	//}
}